import { Crud, BaseController } from '@aipeli/midway-crud';
import { Get, Inject, Query } from '@midwayjs/decorator';
import { ShopUserEntity } from '../../entity/user';
import { ShopUserService } from '../../service/user';
import { RouterMiddleware } from '../../middleware/router';

@Crud(
  {
    // http://127.0.0.1:7001/admin/shop/user/add (delete, update, info, list, page)
    api: ['add', 'delete', 'update', 'info', 'list', 'page'],
    entity: ShopUserEntity,
    queryOption: {
      likeFields: [],
    },
  },
  { middleware: [RouterMiddleware] }
)
export class ShopAdminUserController extends BaseController {
  @Inject()
  userService: ShopUserService;

  // http://127.0.0.1:7001/admin/shop/user/get_user?id=1
  @Get('/get_user')
  async get_user(@Query('id') id) {
    const user = await this.userService.getUser(id);
    return this.success(user);
  }
}
